home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
PGM_TOOL
/
TPRCDR10
/
TPRECDIR.INT
< prev
next >
Wrap
Text File
|
1993-12-26
|
6KB
|
108 lines
{ ╔═══════════╤════════════════════════════════════════════════╗
║ Programmer│ Tony Papadimitriou ║
║ Unit │ TPRecDir (Recursive Directory) ║
║ Uses │ Dos ║
║ Includes │ Nothing ║
║ Created │ Saturday, December 18, 1993 8:34 pm ║
║ Updated │ Sunday, December 26, 1993 11:26 pm ║
║ Language │ (MSDOS) Turbo Pascal 6.0 ║
║ Purpose │ Calls a user routine with a file handle based ║
║ │ on the recursive file search parameters given. ║
╟───────────┴┬──────── Version History ──────────────────────╢
║ 1.00 931218│Original ║
║ 1.10 931225│Added MkChDir function ║
║ 1.20 931226│Added GetMask and GetPath functions ║
╚════════════╧═══════════════════════════════════════════════╝ }
Unit TPRecDir;
{ ╔════════════════════════════════════════════════════════════╗
║ U N I T I N T E R F A C E S E C T I O N ║
╚════════════════════════════════════════════════════════════╝ }
interface
uses
{$ifdef VER60} {$ifopt G+} CPU286, {$endif} {$endif}
Dos;
var
errorsFound: Boolean; { True if there errors during last call to ForEachFileIn }
{ ╔═══════════╤════════════════════════════════════════════════╗
║ Routine │ ForEachFileIn ║
║ Purpose │ Keep calling routine pointed by userRoutine ║
║ │ until all files have been processed. ║
║ │ Return the number of files processed. ║
║ Note(s) │ The user routine must be declared FAR and have ║
║ │ a header similar to the following: ║
║ │ function User(s: SearchRec): Boolean; far; ║
║ │ This function should return True if there were ║
║ │ no problems, and False otherwise. ║
║ │ The s variable will hold the SearchRec of each ║
║ │ file that is matched by this routine. ║
║ │ If the userRoutine pointer is NIL then no ║
║ │ user routine will be called, and the routine ║
║ │ will simply return the number of files found. ║
║ │ Forward slashes are allowed in the work path. ║
╚═══════════╧════════════════════════════════════════════════╝ }
function ForEachFileIn(workPath, { beginning directory, e.g., 'E:\TMP' }
fileMask: String; { file mask, e.g., '*.BAK' }
attr: Word; { file attribute to match }
monitorEsc: Boolean; { if True, an ESC press will cause immediate return }
recurseOn: Boolean; { if True, it will recurse subdirectories }
userRoutine: pointer): Longint;
{ ╔═══════════╤════════════════════════════════════════════════╗
║ Routine │ IsGlobalMask ║
║ Purpose │ Return True if mask passed is equivalent to ║
║ │ '*.*', such as '*??.???' for example. ║
╚═══════════╧════════════════════════════════════════════════╝ }
function IsGlobalMask(mask: String): Boolean;
{ ╔═══════════╤════════════════════════════════════════════════╗
║ Routine │ IsValidMask ║
║ Purpose │ Return True if mask passed does NOT contain ║
║ │ any of the following characters: ║
║ │ < > = , ; : [ ] / \ + ║
╚═══════════╧════════════════════════════════════════════════╝ }
function IsValidMask(mask: String): Boolean;
{ ╔═══════════╤════════════════════════════════════════════════╗
║ Routine │ AttributeMatches ║
║ Purpose │ Return True if attr1 and attr2 have any bits ║
║ │ in common. ║
╚═══════════╧════════════════════════════════════════════════╝ }
function AttributeMatches(attr1,attr2: Word): Boolean;
{ ╔═══════════╤════════════════════════════════════════════════╗
║ Routine │ MaskMatches ║
║ Purpose │ Return True if filename can be matched by mask ║
║ Note(s) │ Mask may contain multiple masks delimited by ; ║
╚═══════════╧════════════════════════════════════════════════╝ }
function MaskMatches(filename,mask: String): Boolean;
{ ╔═══════════╤════════════════════════════════════════════════╗
║ Routine │ MkChDir ║
║ Purpose │ Create (if non-existant) dir tree and change ║
║ │ to it. Returns True on success. ║
╚═══════════╧════════════════════════════════════════════════╝ }
function MkChDir(dir: String): Boolean;
{ ╔═══════════╤════════════════════════════════════════════════╗
║ Routine │ GetMask ║
║ Purpose │ Return the multiple masks from a given argument║
╚═══════════╧════════════════════════════════════════════════╝ }
function GetMask(path: String): String;
{ ╔═══════════╤════════════════════════════════════════════════╗
║ Routine │ GetPath ║
║ Purpose │ Return the path/no masks from a given argument ║
╚═══════════╧════════════════════════════════════════════════╝ }
function GetPath(path: String): String;
{ ╔════════════════════════════════════════════════════════════╗
║ U N I T I M P L E M E N T A T I O N S E C T I O N ║
╚════════════════════════════════════════════════════════════╝ }
implementation